/*
 * Creater:     柿子
 * CreateDate:  2023/07/05
 * Describe：   Iframe外链界面弹窗展示
 * */
import React, { Component } from 'react';
import { Modal } from 'antd';

class IframeModal extends Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: false,
      url: '', // 外链地址
    };
  }

  componentDidMount() {
    this.props.onRef && this.props.onRef(this);
  }

  // 修改弹窗状态
  modifyVisible = (visible, url = '') => {
    this.setState({ visible, url })
  }

  render() {
    let { title, width, height, maskClosable = false, bodyPadding } = this.props;
    let { visible, url } = this.state;
    return (
      <Modal
        visible={visible}
        footer={null}
        width={width || '80vw'}
        title={title && title !== 'none' && title !== 'hide' ? title : ''}
        bodyStyle={{ padding: bodyPadding ? bodyPadding : 0 }}
        maskClosable={maskClosable}
        onCancel={() => this.modifyVisible(false)}
      >
        <iframe
          style={{ width: '100%', height: height || '70vh' }}
          allowFullScreen={true}
          scrolling={'no'}
          src={url}
        />
      </Modal>
    )
  }
};

export default IframeModal;